package com.xing.server.controller;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.xing.server.base.R;
import com.xing.server.pojo.Employee;
import com.xing.server.pojo.RPageBean;
import com.xing.server.pojo.RespPageBean;
import com.xing.server.pojo.Salary;
import com.xing.server.service.IEmployeeService;
import com.xing.server.service.ISalaryService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 员工帐套
 *
 * @author: xingfuhao
 * @create: 2021-12-29 21:38
 */
@RestController
@RequestMapping("/salarys/sobcfgg")
public class SalarySobCfggController {

    @Autowired
    private ISalaryService salaryService;
    @Autowired
    private IEmployeeService employeeService;

    @ApiOperation(value = "获取所有工资套帐")
    @GetMapping("/s")
    public List<Salary> getAllSalariesaas(){
        return salaryService.list();
    }

//    @ApiOperation(value = "获取所有的员工的账套")
//    @GetMapping("/employeeWithSalary")
//    public RespPageBean getEmployeeWithSalary(@RequestParam(defaultValue = "1")Integer currentPage,
//                                              @RequestParam(defaultValue = "10")Integer size){
//        return employeeService.getEmployeeWithSalary(currentPage,size);
//    }


    @ApiOperation(value = "获取所有员工的套帐的 分页")
    @GetMapping("/a")
    public RPageBean getAlEmployeeWithSalary1a(@RequestParam(defaultValue = "1") Integer currentPage,
                                              @RequestParam(defaultValue = "10")Integer size){
        return employeeService.getAllEmployeeWithSalary(currentPage,size);
    }




    @ApiOperation(value = "更新员工工资账套")
    @PutMapping("/")
    public R updateEmployeeSalarys(Integer eid,Integer sid){
        if(employeeService.update(new UpdateWrapper<Employee>().set("salaryId", sid).set("id", eid))){
            return R.success("更新成功");
        }
        return R.error("更新失败");
    }
}
